package com.zprmb.udzt.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.zprmb.udzt.BbtApplication;
import com.zprmb.udzt.ImageFloder;
import com.zprmb.udzt.R;

public class FolderAdapter extends BaseAdapter{
	private Context context;
	private List<ImageFloder> mDirPaths;
	
	public FolderAdapter(Context context,List<ImageFloder> mDirPaths) {
		this.context = context;
		this.mDirPaths = mDirPaths;
	}
	
	public int getCount() {
		return mDirPaths.size();
	}

	public Object getItem(int position) {
		return null;
	}

	public long getItemId(int position) {
		return 0;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		FolderViewHolder holder = null;
		if (convertView == null) {
			convertView = View.inflate(context, R.layout.list_dir_item,
					null);
			holder = new FolderViewHolder();
			holder.id_dir_item_image = (ImageView) convertView
					.findViewById(R.id.id_dir_item_image);
			holder.id_dir_item_name = (TextView) convertView
					.findViewById(R.id.id_dir_item_name);
			holder.id_dir_item_count = (TextView) convertView
					.findViewById(R.id.id_dir_item_count);
			holder.choose = (ImageView) convertView
					.findViewById(R.id.choose);
			convertView.setTag(holder);
		} else {
			holder = (FolderViewHolder) convertView.getTag();
		}
		ImageFloder item = mDirPaths.get(position);
		//System.out.println("select==-------===" + item.getFirstImagePath());
		BbtApplication.getInstance().display("file://"+item.getFirstImagePath(),holder.id_dir_item_image, R.drawable.bbt_selectimage_bg,1);
		holder.id_dir_item_count.setText(item.images.size() + "张");
		holder.id_dir_item_name.setText(item.getName());
		return convertView;
	}
	class FolderViewHolder {
		ImageView id_dir_item_image;
		ImageView choose;
		TextView id_dir_item_name;
		TextView id_dir_item_count;
	}
}
